package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.net.domain.ElementBusiMplsAlarmbfpVo;
import com.ruoyi.net.domain.NetElement;
import com.ruoyi.net.mapper.NetElementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.net.mapper.ElementBusiMplsAlarmbfpMapper;
import com.ruoyi.net.domain.ElementBusiMplsAlarmbfp;
import com.ruoyi.net.service.IElementBusiMplsAlarmbfpService;

/**
 * 网元-业务-mpls-故障检测bfpService业务层处理
 * 
 * @author net
 * @date 2024-11-17
 */
@Service
public class ElementBusiMplsAlarmbfpServiceImpl implements IElementBusiMplsAlarmbfpService 
{
    @Autowired
    private ElementBusiMplsAlarmbfpMapper elementBusiMplsAlarmbfpMapper;
    @Autowired
    private NetElementMapper elementMapper;
    /**
     * 查询网元-业务-mpls-故障检测bfp
     * 
     * @param id 网元-业务-mpls-故障检测bfp主键
     * @return 网元-业务-mpls-故障检测bfp
     */
    @Override
    public ElementBusiMplsAlarmbfp selectElementBusiMplsAlarmbfpById(String id)
    {
        return elementBusiMplsAlarmbfpMapper.selectElementBusiMplsAlarmbfpById(id);
    }

    /**
     * 查询网元-业务-mpls-故障检测bfp列表
     * 
     * @param elementBusiMplsAlarmbfp 网元-业务-mpls-故障检测bfp
     * @return 网元-业务-mpls-故障检测bfp
     */
    @Override
    public List<ElementBusiMplsAlarmbfpVo> selectElementBusiMplsAlarmbfpList(ElementBusiMplsAlarmbfp elementBusiMplsAlarmbfp)
    {
        List<ElementBusiMplsAlarmbfpVo> elementBusiMplsAlarmbfps = elementBusiMplsAlarmbfpMapper.selectElementBusiMplsAlarmbfpList(elementBusiMplsAlarmbfp);
        for (ElementBusiMplsAlarmbfpVo busiMplsAlarmbfpVo:elementBusiMplsAlarmbfps){
            NetElement netElement = elementMapper.selectNetElementById(busiMplsAlarmbfpVo.getElementId());
            if (netElement != null){
                busiMplsAlarmbfpVo.setElementName(netElement.getElementName());
            }
        }
        return elementBusiMplsAlarmbfps;
    }

    /**
     * 新增网元-业务-mpls-故障检测bfp
     * 
     * @param elementBusiMplsAlarmbfp 网元-业务-mpls-故障检测bfp
     * @return 结果
     */
    @Override
    public int insertElementBusiMplsAlarmbfp(ElementBusiMplsAlarmbfp elementBusiMplsAlarmbfp)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(elementBusiMplsAlarmbfp.getId())) {
            elementBusiMplsAlarmbfp.setId(uuid);
        }
        elementBusiMplsAlarmbfp.setCreateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmbfp.setCreateTime(DateUtils.getNowDate());
        elementBusiMplsAlarmbfp.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmbfp.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMplsAlarmbfpMapper.insertElementBusiMplsAlarmbfp(elementBusiMplsAlarmbfp);
    }

    /**
     * 修改网元-业务-mpls-故障检测bfp
     * 
     * @param elementBusiMplsAlarmbfp 网元-业务-mpls-故障检测bfp
     * @return 结果
     */
    @Override
    public int updateElementBusiMplsAlarmbfp(ElementBusiMplsAlarmbfp elementBusiMplsAlarmbfp)
    {
        elementBusiMplsAlarmbfp.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmbfp.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMplsAlarmbfpMapper.updateElementBusiMplsAlarmbfp(elementBusiMplsAlarmbfp);
    }

    /**
     * 批量删除网元-业务-mpls-故障检测bfp
     * 
     * @param ids 需要删除的网元-业务-mpls-故障检测bfp主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMplsAlarmbfpByIds(String[] ids)
    {
        return elementBusiMplsAlarmbfpMapper.deleteElementBusiMplsAlarmbfpByIds(ids);
    }

    /**
     * 删除网元-业务-mpls-故障检测bfp信息
     * 
     * @param id 网元-业务-mpls-故障检测bfp主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMplsAlarmbfpById(String id)
    {
        return elementBusiMplsAlarmbfpMapper.deleteElementBusiMplsAlarmbfpById(id);
    }
}
